#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
from sage.all import *
from curves import *

# from handbook of elliptic and hyperellptic curves, page 397
q = 13
n = 7
subfield = GF(q)
subpoli = PolynomialRing(subfield, 'x')
y = subpoli.gen()
field = GF(q ** 2, 'a', modulus = y ** 2 - 2)
a = field.gen()
Px = PolynomialRing(field, 'x')
x = Px.gen()
f = x ** 3 + 6
c = Curve.createSimpleCurve(f, Px)
dd = [x - 2, Px(1)]
ee = [x - (10 + 3 * a), Px(11 + 2 * a)]
D = c.divisorOf(dd)
E = c.divisorOf(ee)

S = n

d = (q ** embeddingDegree(q, n) - 1) / S
resultado = c.miller (S, d, D, E)
print "the result is %r" % resultado
print "expected = a + 4"

